import axios from "./index.js";
import qs from "qs";
// 返回所有用户信息
export const GetUsers = (data) => {
  return axios.request({
    url: "/brac/account/listUser",
    method: "get",
    data: data
  });
};

// 返回所有用户信息
export const GetSystemUsers = (data) => {
  return axios.request({
    url: "system/account/listUser",
    method: "get",
    data: data
  });
};

// 组织机构列表数据查询
export const GetOrgTree = (data) => {
  return axios.request({
    url: "/system/organization/tree",
    method: "post",
    data: data
  });
};
// 组织机构列表数据查询   -- level =  1
export const GetOrgTreeOne = (data) => {
  return axios.request({
    url: "/system/organization/provinceChooseTree",
    method: "post",
    data: data
  });
};
// 组织机构列表数据查询   -- level =  2
export const GetOrgTreeTwo = (data) => {
  return axios.request({
    url: "/system/organization/cityChooseTree",
    method: "post",
    data: data
  });
};
// 组织机构列表数据查询   -- level =  3  4 5 6
export const GetOrgTreeMore = (data) => {
  return axios.request({
    url: "/system/organization/districtChooseTree",
    method: "post",
    data: data
  });
};
// system/organization/getOrgList
export const getOrgListTree = (data) => {
  return axios.request({
    url: "/system/organization/getOrgList",
    method: "get",
    data: data
  });
};

// 根据单位查询相关人员
export const GetByOrganization = (data) => {
  return axios.request({
    // url: "/brac/account/listAccountByOrganization",
    url: "/system/account/getAccountByOrgAll",
    method: "get",
    data: data
  });
};
// 根据部门查询相关人员
export const getAccountByOrg = (data) => {
  return axios.request({
    url: "/system/account/getAccountByOrg",
    method: "post",
    data: data
  });
};

export const listAccountByOrganization = (data) => {
  return axios.request({
    url: "/system/account/getAccountOrgInfoList",
    // url: "/brac/account/getAccountByOrgAll",
    method: "get",
    data: data
  });
};

// 字典表查询下拉框 预警管理模块
export const getDictByGroup = (data) => {
  return axios.request({
    // url: "/setting/dict/getDictList",
    // url: "/warning/dict/getDictByGroup",
    url: "/setting/dict/getDictList",
    method: "get",
    data: data
  });
};
// 字典表查询下拉框 应急处置模块
export const getDictByGroupEmergency = (data) => {
  return axios.request({
    url: "/setting/dict/getDictList",
    method: "get",
    data: data
  });
};

// 责任单位及部门
export const sameLeveltree = (data) => {
  return axios.request({
    url: "/system/organization/sameLeveltree",
    method: "get",
    data: data
  });
};

// 部门 列表
export const BaseMockDepartment = (data) => {
  return axios.request({
    // url: "/emergency/baseMock/department",
    url: "/brac/organization/getOrganization",
    method: "get",
    data: data
  });
};
// 负责人
export const BaseMockPerson = (data) => {
  return axios.request({
    // url: "/emergency/baseMock/person",
    url: "/brac/account/listUser",
    method: "get",
    data: data
  });
};
// 已发布命令单数据接口
export const GetResponse = (data) => {
  return axios.request({
    url: "/emergency/emergencyResponse/selectResponse",
    method: "get",
    data: data
  });
};

// 左侧业务流程
export const GetFlowList = (data) => {
  return axios.request({
    url: "/emergency/warningFlow/listPage",
    method: "post",
    data: data
  });
};

// 下载文件
export const viewNew = (data) => {
  return axios.request({
    url: "/fileyj/upDown/view",
    method: "get",
    data: data
  });
};

// 选择队伍列表
export const GetTeam = (data) => {
  return axios.request({
    url: "/resource/baseResourceTeam/listPage",
    method: "post",
    data: data
  });
};
// 队员选择列表
export const GetTeamMember = (data) => {
  return axios.request({
    url: "/resource/baseResourceMember/listPage",
    method: "post",
    data: data
  });
};
// 装备选择列表
export const GetEquip = (data) => {
  return axios.request({
    url: "/resource/baseResourceEquip/listPage",
    method: "post",
    data: data
  });
};
// 车辆选择列表
export const GetVehicle = (data) => {
  return axios.request({
    url: "/resource/baseResourceVehicle/listPage",
    method: "post",
    data: data
  });
};
// 上传
export const UploadFile = (data) => {
  return axios.request({
    url: "/fileyj/upDown/upload",
    method: "post",
    data: data
  });
};

// 下载
export const loadFile = (data) => {
  data.token = JSON.parse(sessionStorage.getItem("accessToken"));
  return axios.request({
    url: "/fileyj/upDown/view",
    method: "get",
    data: data,
    responseType: "blob"
  });
};
// PDF预览
export const fileArraybuffer = (data) => {
  data.token = JSON.parse(sessionStorage.getItem("accessToken"));
  return axios.request({
    url: "/fileyj/upDown/view",
    method: "get",
    data: data,
    responseType: "arraybuffer"
  });
};


// dic公共字典接口
export const dicList = (data) => {
  return axios.request({
    url: `/system/dic/getDicList`,
    method: "get",
    data: data
  });
};

// 批量查询字典数据
export const getBatchDicList = (data) => {
  const params = qs.stringify(data, { arrayFormat: "repeat" });
  return axios.request({
    url: `/system/dic/getBatchDicList?${params}`,
    method: "post"
  });
};

// 首页单位筛选
export const getResourceLevelUnit = (data) => {
  return axios.request({
    url: "/system/organization/getResourceLevelUnit",
    method: "get",
    data: data
  });
};
// 应急资源查询下一级单位
export const getEmergencyResourcesUnit = (data) => {
  return axios.request({
    url: "/system/organization/getResourceLevelCity",
    method: "get",
    data: data
  });
};

export const getLevelCitys = (data) => {
  return axios.request({
    url: "/system/organization/getLevelCitys",
    method: "get",
    data: data
  });
};
// 获取全省各地市天气
export const getByAreaNameAndTime = (areaName, date) => {
  return axios.request({
    url: `/docking/futureDaily/getByAreaNameAndTime?areaName=${areaName}&date=${date}`,
    method: "get"
  });
};

// 获取气象格点值
export const getGridByAreaAndTime = (type, date) => {
  return axios.request({
    url: `/docking/provincialGrid/getGrid?type=${type}&date=${date}`,
    method: "get"
  });
};
// 获取天气预警信息
export const getEarlyWarningList = (data) => {
  return axios.request({
    url: `/docking/earlyWarning/doList`,
    method: "post",
    data: data
  });
};
// 菜单删除
export const deleteMenuByIds = (data) => {
  return axios.request({
    url: `/system/menu/deleteByIds`,
    method: "post",
    data: data
  });
};

// 获取单位及部门
export const getOrgDepartmentName = (orgId) => {
  return axios.request({
    url: `/system/organization/getOrgDepartmentName?orgId=${orgId}`,
    method: "get"
  });
};
// 组织机构列表  -- 单位
export const getSubclassUntilList = (data) => {
  return axios.request({
    url: "/system/organization/getSubclassUntilList",
    method: "get",
    data: data
  });
};

// 查询指定组织机构往下的树结构（包含部门）
export const getOrgDepartmentList = (data) => {
  return axios.request({
    url: "/system/organization/getOrgDepartmentList",
    method: "get",
    data: data
  });
};
export const getOrggetSameLevel = (data) => {
  return axios.request({
    url: "/system/organization/getSameLevel",
    method: "get",
    data: data
  });
};
// export const getOrggetSameLevelTree = (orgId) => {
//   return axios.request({
//     url: `/system/organization/getSameLevel?orgId=${orgId}`,
//     method: "get"
//     // data: data
//   });
// };
export const getOrggetSameLevelTree = (data) => {
  return axios.request({
    url: `/system/organization/getSameLevel?orgId=${data}`,
    method: "get"
  });
};
// 查询本级单位及上一级的单位部门
export const getUpDepartment = (data) => {
  return axios.request({
    url: "/system/organization/getUpDepartment",
    method: "get",
    data: data
  });
};

// 查询本级单位及下一级的单位部门
export const getDepartmentNext = (data) => {
  return axios.request({
    url: "/system/organization/getDepartmentNext",
    method: "get",
    data: data
  });
};

// 查询本级及下级的单位（不包含部门）
export const getUnitAndNextUnit = (data) => {
  return axios.request({
    url: "/system/organization/getUnitAndNextUnit",
    method: "get",
    data: data
  });
};
export const getUntilList = (data) => {
  return axios.request({
    url: "/system/organization/getUntilList",
    method: "get",
    data: data
  });
};

// 根据部门查询相关人员
export const getAccountOrgById = (data) => {
  return axios.request({
    url: "/system/account/getAccountOrgById",
    method: "get",
    data: data
  });
};

// 获取当前登录人同级部门组织机构
export const getOrgSameLevelDept = (data) => {
  return axios.request({
    url: "/system//organization/getOrgSameLevelDept",
    method: "get",
    data: data
  });
};
// 获取当前登陆人同部门人员
export const getAccountDeptList = (data) => {
  return axios.request({
    url: "/system//account/getAccountDeptList",
    method: "get",
    data: data
  });
};

// 查询指定组织机构的上级单位
export const getSuperiorUntilId = (data) => {
  return axios.request({
    url: `/system/organization/getSuperiorUntilId?orgId=${data}`,
    method: "get"
  });
};

// 获取当前角色权限控制
export const rolePower = (data) => {
  return axios.request({
    url: "/system/menuRoleComponent/listPage",
    method: "post",
    data: data
  });
};

// 查询当前角色关联的菜单按钮
export const getMenuTreeByRoles = (data) => {
  return axios.request({
    url: `/system/menu/getMenuTreeByRoles?roleId=${data}`,
    method: "get"
  });
};
